home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 001-025 / scopedisk1 / getopt / getopt.doc next >
Text File  |  1995-03-18  |  2KB  |  52 lines

  1.  
  2. GETOPT
  3.  
  4. NAME
  5.  
  6.     getopt - Get next option letter from argument vector.
  7.  
  8. USAGE
  9.  
  10.     int getopt(argc, argv, optstring);
  11.  
  12.     #include "getopt.h"
  13.  
  14.     int argc;
  15.     char *argv[], *optstring;
  16.     extern char *optarg;
  17.     extern int optind, opterr, optopt;
  18.  
  19. DESCRIPTION
  20.  
  21.     The function getopt() returns the next option letter in argv that
  22. matches a letter in optstring.  Optstring is a string of valid option
  23. letters; if an option letter is followed by a colon (:), that option
  24. is expected to have an argument that may or may not be separated from
  25. it by white space.  Optarg is set to point to the start of the option's
  26. argument on return from getopt();
  27.  
  28.     getopt() places in optind the argv index of the next argument to be
  29. parsed.  Optind is external, and is initialized to 1 before the first
  30. call to getopt().
  31.  
  32.     When all options have been parsed (that is, up to the first non-
  33. option argument), getopt returns EOF.  The special option double dash
  34. (--) may be used to delimit the end of the options.  EOF will be
  35. returned and the double dash will be skipped.  The special option single
  36. dash (-) may be used to indicate that stdin should be used as the next
  37. input stream. EOF will be returned but the single dash will not be skipped.
  38. The calling routine must then act on the presence of the single dash in the
  39. argument vector.
  40.  
  41. DIAGNOSTICS
  42.  
  43.     If the external variable opterr is non-zero (the default) getopt()
  44. prints an error message on stderr and returns a question mark (?) when
  45. it encounters either an option character not in optstring or a valid
  46. option without its required argument.
  47.  
  48.     In those cases where getopt() finds an option character not in
  49. optstring, and returns a question mark, the external variable optopt
  50. will contain the actual character found.
  51.  
  52.